#!/usr/bin/php
<?php

include "config.php";

$in = $argv[1];
$out = $argv[2];

$inFile = fopen($in, "r") or exit("Unable to open file ".$in);
$outFile = fopen($out, "w")  or exit("Unable to create file ".$out);
while (!feof($inFile)) {
    $line = trim(fgets($inFile));
    $len = strlen($line);
    if ($len == 0)
        continue;

    if ($len <= LINE_LENGTH) {
        for ($i = 0; $i < LINE_LENGTH - $len; $i++) {
            $line .= " ";
        }
        $line .= "\n";
        fwrite($outFile, $line);
    } else {
        fwrite($outFile, substr($line, 0, LINE_LENGTH)."\n");
    }
}
fclose($inFile);
fclose($outFile);

?>

